
    function sellStock(stock_code,stock_name,stock_nums,stock_price) {
        $("#sell_stock_code").textbox('setValue', stock_code)
        $("#sell_stock_name").textbox('setValue', stock_name)
        $("#sell_stock_amount").textbox('setValue', stock_nums)
        $("#sell_stock_price").textbox('setValue', stock_price)
        $("#win_sell_stock").window('open')

    }

    function query_lifeline(stock) {
        // 加载股价信息
        $.ajax({
            /*type = "get",*/
            url: '/lifeline/stock-price',
            dateType: "JSON",
            data: {"stock_code": stock},
            success: function (data, textStatus, jqXHR) {
                if (data) {
                    $("#stock_code").textbox('setValue', stock);
                    $("#stock_name").textbox('setValue', data.stock_name);
                    $("#cur_price").textbox('setValue', data.now);
                    $("#open").textbox('setValue', data.open);
                    $("#high").textbox('setValue', data.high);
                    $("#low").textbox('setValue', data.low);

                }


            }
        });

        // 支撑线
        $.ajax({
            /*type = "get",*/
            url: '/lifeline/stock-pressureline',
            dateType: "JSON",
            data: {"stock_code": stock},
            success: function (data, textStatus, jqXHR) {
                if (data) {
                    $("#press_id").val(data.id);
                    $("#press_price").textbox('setValue', data.point_1_price)
                    $("#press_time").textbox('setValue', dateFormatter1(data.point_1_time))

                }
            }
        });

        // 阻力线
        $.ajax({
            /*type = "get",*/
            url: '/lifeline/stock-supportline',
            dateType: "JSON",
            data: {"stock_code": stock},
            success: function (data, textStatus, jqXHR) {
                if (data) {
                    $("#support_id").val(data.id);
                    $("#support_price").textbox('setValue', data.point_1_price);
                    $("#support_time").textbox('setValue', dateFormatter1(data.point_1_time));

                }
            }
        });

        // 弹窗
        $('#win_lifeline').window('open'); // open a window
    }



    var stockholder = {                     //obj对象
        search: function () {
            $('#stock_holder_table').datagrid('load', $("#stockholders_form").parseForm());
        }
    };


    $('#stock_holder_table').datagrid({
        // width: 1500,                 //设置宽度
        url: '/holder/query-list',       //远程加载数据地址
        title: '持股数据',           //面板属性，添加标题
        iconCls: 'icon-search',     //添加图标
        method: 'get',
        queryParams: $("#stockholders_form").parseForm(),
        selectOnCheck: true,
        columns: [[                 //设置要显示表格数据
            {
                field: 'id',
                checkbox: true
            },
            {
                field: 'stock_name',
                title: '股票名称',
                resizable: true,
                formatter: linkStockDetail

            },
            {
                field: 'stock_code',
                title: '股票编码',
                resizable: true,
                width: 30
            },
            {
                field: 'market',
                title: '市场',
                resizable: true,
                width: 10
            }
            , {
                field: 'average_price',
                title: '持仓平均价格',
                resizable: true,
                width: 30
            }
            , {
                field: 'cur_nums',
                title: '当前持股数',
                resizable: true,
                width: 30
            }
            , {
                field: 'create_time',
                title: '创建时间',
                resizable: true,
                width: 40,
                formatter: dateFormatter
            }
              , {
                field: 'update_time',
                title: '更新时间',
                resizable: true,
                width: 40,
                formatter: dateFormatter
            }
            , {
                title: '操作',
                // resizable: true,
                field: '获取最新数据大厦的方式',
                width: 60,
                formatter: formatOper
            }
        ]],
        pagination: true,
        pageNumber: 1,
        pageSize: 10,
        pageList: [10, 20, 30],
        fitColumns: true,
        rownumbers: true,
        toolbar: '#stockholders_toolbar'
    });

    $('#stockHolder_search').linkbutton({  //查询按钮
        iconCls: "icon-search"
    });
    //查询功能
    $('#stockHolder_search').click(function () {   //点击查询后执行obj对象里的search方法
        stockholder.search();
    });

    function formatOper(val, row, index) {

        return  ' <button class="easyui-linkbutton" onclick="query_lifeline(\'' + row.stock_code + '\')">查看当前生命线</button> ' +
            "<button class='easyui-linkbutton' onclick=\"sellStock('" + row.stock_code + "','" + row.stock_name + "','" + row.cur_nums + "','" + row.average_price + "')\">卖出股票</button>"
    }
